package com.xja.webchat.service.impl;

import com.xja.webchat.entity.Message;
import com.xja.webchat.mapper.MessageMapper;
import com.xja.webchat.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service("messageService")
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;
    @Override

    public List<Message> selectMassageList(Map<String, Integer> map) {
        messageMapper.updateMessageStatus(map);
        return messageMapper.selectMassageList(map);
    }

    @Override
    public void updateMessageStatus(Map<String, Integer> map) {
        messageMapper.updateMessageStatus(map);
    }

    @Override
    @Transactional(propagation= Propagation.REQUIRED)
    public void addMessage(Message message) {
        messageMapper.insert(message);
    }
}
